package com.rxh.controller;


import com.rxh.pojo.Result;
import com.rxh.service.OperationService;
import com.rxh.spring.annotation.SystemLogInfo;
import com.rxh.vo.VoAbnormal;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: 王德明
 * Date: 2018/5/16
 * Time: 10:56
 * Project: Management_new
 * Package: com.rxh.controller
 */
@Controller
@RequestMapping(value = "/operation")
public class OperationController {

    @Resource
    private OperationService operationService;


    /**
     *   异常订单管理
     */
    //获取下拉框数据
    @RequestMapping(value = "/getInit")
    @ResponseBody
    public Map<String, Object> getInit() {
        return operationService.getInit();
    }

    //获取全部数据
    @SystemLogInfo( description = "Abnormal")
    @RequestMapping(value = "/getAbnormal")
    @ResponseBody
    public List<VoAbnormal> getAbnormal(@RequestBody(required = false) Map<String,Object> paramMap) {
        return operationService.getcoreOrderChangeInfo(paramMap);
    }

    //查询数据
    @RequestMapping(value = "/getAbnormalCheck")
    @ResponseBody
    public List<VoAbnormal> getAbnormalCheck(@RequestBody Map<String,Object> paramMap) {
        return operationService.getAbnormalCheck(paramMap);
    }

    /**
     * 审核数据
     * @param voAbnormal
     * @return
     */
    @RequestMapping(value = "/getAbnormalAudit")
    @ResponseBody
    public Result updateAbnormalAudit(@RequestBody VoAbnormal voAbnormal) {
        voAbnormal.setAuditor(SecurityContextHolder.getContext().getAuthentication().getName());
        voAbnormal.setAuditTime(new Date());
        return operationService.updateAbnormalAudit(voAbnormal);
    }


    /**
     *   提现管理
     */
    //获取全部数据
    @SystemLogInfo( description = "Withdrawal")
    @RequestMapping(value = "/getWithdrawal")
    @ResponseBody
    public List<Map<String,Object>> getWithdrawal(@RequestBody(required = false) Map<String,Object> paramMap) {
        return operationService.getWithdrawal(paramMap);
    }

    //查询数据
    @RequestMapping(value = "/getWithdrawalCheck")
    @ResponseBody
    public List<Map<String,Object>> getWithdrawalCheck(@RequestBody Map<String,Object> paramMap) {
        return operationService.getWithdrawalCheck(paramMap);
    }

    //审核数据
    @RequestMapping(value = "/getWithdrawalAudit")
    @ResponseBody
    public Boolean getWithdrawalAudit(@RequestBody Map<String,Object> paramMap) {
        paramMap.put("currentUser", SecurityContextHolder.getContext().getAuthentication().getName());
        operationService.updateWithdrawalAudit(paramMap);
        return true;
    }


    //打印表格 数据
    @RequestMapping(value = "/getreviewPrintData")
    @ResponseBody
    public List<Map<String,Object>> getreviewPrintData(@RequestBody Map<String,Object> paramMap) {

        return operationService.getreviewPrintData(paramMap);

    }


}
